package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
@Setter
@ToString
@JsonIgnoreProperties("handler")
public class StrategyCatalog extends BaseDomain {

    private String name;

    private Strategy strategy;

    private Integer sequence;

    private boolean state;

    private List<StrategyDetail> details = new ArrayList<>();

    public String getStateName(){
        String temp = "启用";
        if(!state) {
            temp = "禁用";
        }
        return temp;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",getId());
        map.put("name",name);
        map.put("sequence",sequence);
        if(strategy != null){
             map.put("strategyId",strategy.getId());
        }
        map.put("state",state);
        return JSONUtils.toJSONString(map);
    }


}